<!--初始的版本，使用了穿梭框控件-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>课程编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui2.css" media="all">
</head>
<body>
<form class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">任课教师</label>
        <div class="layui-input-block">
            <select name="cou_adm_id" lay-verify="">
                {volist name="teacherInfo" id="vo"}
                <option value="{$vo['adm_id']}"  {if $vo['adm_id']==$courseInfo['cou_adm_id']}selected{/if} >{$vo['adm_realname']}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">课程名称</label>
        <div class="layui-input-block">
            <input id="" type="text" name="cou_name" value="{$courseInfo['cou_name']}" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">课程开始</label>
        <div class="layui-input-block">
            <input type="text" name="cou_start_time" class="layui-input" id="startTime" placeholder="yyyy-MM-dd" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">课程结束</label>
        <div class="layui-input-block">
            <input type="text" name="cou_end_time" class="layui-input" id="endTime" placeholder="yyyy-MM-dd" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">添加学生</label>
        <div class="layui-input-block">
            <div id="test4" class="demo-transfer"></div>
        </div>
    </div>
    <input type="hidden" name="studentInCourse" id="studentInCourse" >

    <div class="layui-form-item layui-hide">
        <button class="layui-btn" lay-submit lay-filter="LAY-course-edit-submit" id="LAY-course-edit-submit">提交</button>
    </div>



</form>
<script src="/static/indexTemplate/lib/jquery-2.1.4.js"></script>
<script src="/static/layuiadmin/layui/layui.js"></script>

<script>

    var data={$studentData};
    dataStr=JSON.stringify(data);
    $("#studentInCourse").val(dataStr);
    function getTransferData(){
        var val = '';
        $.ajax({
            url:"{:url('admin/course/getEditTransferData')}?cou_id={$courseInfo['cou_id']}",
            type:"post",
            dataType:"json",
            async:false,
            success:function(res){
                val = res;
            },
            error:function (res) {
                return '';
            }
        })
        return val;
    }

    $(function () {
        layui.config({
            base: '/static/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form',"laydate","transfer"], function () {
            var $ = layui.$
                , form = layui.form
                ,laydate=layui.laydate
                ,transfer=layui.transfer;
            form.on('submit(LAY-course-edit-submit)', function (data) {
            });
            laydate.render({
                elem: '#startTime'
                ,trigger: 'click'
                ,value:"{$courseInfo['cou_start_time']}"
                ,type: 'datetime'
            });

            laydate.render({
                elem: '#endTime'
                ,trigger: 'click'
                ,value:"{$courseInfo['cou_end_time']}"
                ,type: 'datetime'
            });

            var responseData=getTransferData();

            //模拟数据
            var data = responseData['data'];
            var value=responseData['value'];
            //显示搜索框
            transfer.render({
                id:"transfer"
                ,elem: '#test4'
                ,data: data
                ,value:value
                ,title: ['未报名学生', '已报名学生']
                ,width:"300"
                ,height:"440"
                ,showSearch: true
                ,onchange: function(data, index){
                    //获得右侧数据
                    var getData = transfer.getData('transfer');
                    data=JSON.stringify(getData)
                    $("#studentInCourse").val(data);
                }
            })

        });
    });




</script>
</body>
</html>
